<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j"
    template="../WEB-INF/layout/template.xhtml">

  <ui:define name="center_content">
    <a4j:form id="registerForm" rendered="#{zanataInit.internalAuthentication}">
      <s:token allowMultiplePosts="true" />
      <rich:panel>
        <f:facet name="header">#{messages['jsf.SignUp']}</f:facet>

        <s:decorate id="nameField" template="../WEB-INF/layout/edit.xhtml">
            <ui:define name="label">#{messages['jsf.Name']}</ui:define>
            <h:inputText id="name" required="true"
                      value="#{register.person.name}">
               <a4j:support event="onblur" reRender="nameField" ajaxSingle="true"/>
            </h:inputText>
            <h:graphicImage id="nameHelp" value="../img/msginfo.png" styleClass="input_help">
              <rich:toolTip>
                #{messages['jsf.NameToolTip']}
              </rich:toolTip>
            </h:graphicImage>
        </s:decorate>

        <s:decorate id="emailField" template="../WEB-INF/layout/edit.xhtml">
            <ui:define name="label">#{messages['jsf.Email']}</ui:define>
            <h:inputText id="email" required="true"
                      value="#{register.person.email}">
               <a4j:support event="onblur" reRender="emailField" ajaxSingle="true"/>
            </h:inputText>
            <h:graphicImage id="emailHelp" value="../img/msginfo.png" styleClass="input_help">
              <rich:toolTip>
                #{messages['jsf.EmailToolTip']}
              </rich:toolTip>
            </h:graphicImage>
        </s:decorate>

        <s:decorate id="usernameField" template="../WEB-INF/layout/edit.xhtml">
            <ui:define name="label">Username</ui:define>
            <h:inputText id="username" required="true"
                      value="#{register.username}">
               <a4j:support event="onblur" reRender="usernameField" ajaxSingle="true"/>
            </h:inputText>
            <h:graphicImage id="usernameHelp" value="../img/msginfo.png" styleClass="input_help">
              <rich:toolTip>
                #{messages['jsf.UsernameToolTip']}
              </rich:toolTip>
            </h:graphicImage>
        </s:decorate>
        <s:decorate id="passwordField" template="../WEB-INF/layout/edit.xhtml">
            <ui:define name="label">#{messages['jsf.Password']}</ui:define>
            <h:inputSecret id="password" redisplay="true" required="true"
                        value="#{register.password}">
              <a4j:support event="onblur" reRender="passwordField" ajaxSingle="true"/>
            </h:inputSecret>
        </s:decorate>
        <s:decorate id="passwordConfirmField" template="../WEB-INF/layout/edit.xhtml">
            <ui:define name="label">#{messages['jsf.ConfirmPassword']}</ui:define>
            <h:inputSecret id="passwordConfirm" redisplay="true" required="true"
                        value="#{register.passwordConfirm}">
              <a4j:support event="onblur" reRender="passwordConfirmField" ajaxSingle="true"/>                        
            </h:inputSecret>
        </s:decorate>
        <s:decorate id="captcha" template="../WEB-INF/layout/edit.xhtml">
            <ui:define name="label"><h:graphicImage value="/seam/resource/captcha"/></ui:define>
            <h:inputText id="verifyCaptcha" value="#{captcha.response}" required="true"/>
        </s:decorate>
        
        <s:decorate id="agreedToTerms" template="../WEB-INF/layout/edit.xhtml">
          <h:selectBooleanCheckbox id="agreedToTerms" value="#{register.agreedToTermsOfUse}"/>
          <label for="agreedToTerms">
            #{messages['jsf.IAgreeToThe']}
            <h:outputLink value="#" id="termsOfUseLink">
              <h:outputText value="#{messages['jsf.TermsOfUse']}"/>
              <rich:componentControl for="termsOfUse" attachTo="termsOfUseLink" operation="show" event="onclick"/>
            </h:outputLink>
          </label>
        </s:decorate>
        
        <div style="clear:both"/>
        <div class="actionButtons">
            <h:commandButton value="#{messages['jsf.Register']}" action="#{register.register}"/>
        </div>
      </rich:panel>
    </a4j:form>
    
    <rich:modalPanel id="termsOfUse" width="640" height="480" rendered="#{not identity.loggedIn and zanataInit.internalAuthentication}" >
      <f:facet name="header">
        <h:panelGroup>
          <h:outputText value="#{messages['jsf.TermsOfUse']}"/>
        </h:panelGroup>
      </f:facet>
      <f:facet name="controls">
        <h:panelGroup>
          <h:graphicImage value="../img/close.gif" styleClass="hidelink" id="hideTermsLink"/>
          <rich:componentControl for="termsOfUse" attachTo="hideTermsLink" operation="hide" event="onclick"/>
        </h:panelGroup>
      </f:facet>
      <a4j:include viewId="/legal.html"/>
      <h:panelGroup style="width: 600px; text-align: center;">
        <a4j:form>
          <rich:spacer height="40"/>
          <a4j:commandButton value="#{messages['jsf.Close']}" onclick="#{rich:component('termsOfUse')}.hide()"/>
        </a4j:form>
      </h:panelGroup>
    </rich:modalPanel>
 
    <rich:panel rendered="#{not zanataInit.internalAuthentication}">
          <h:outputText value="#{messages['jsf.PleaseContactAdministrationToGetRegistrationLink']}"/>
    </rich:panel>
   
  </ui:define>
  
  
  
</ui:composition>
